unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.OleServer, Word_TLB,
  ComObj;

type
  TForm1 = class(TForm)
    Btnx_1: TButton;
    WPSApplication1: TWPSApplication;
    procedure Btnx_1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  WPSAPP:OleVariant;

implementation

uses
  class_kzutils;

{$R *.dfm}

procedure TForm1.Btnx_1Click(Sender: TObject);
var
  FileName:OleVariant;
begin
  {WPSAPP:=CreateOleObject('kwps.application');
  WPSAPP.Visible:=True;
  WPSAPP.Docuemnts.Open(TKzUtils.ExePath+'00001.doc');}

  FileName:=TKzUtils.ExePath + '00001.doc';

  ShowMessage(FileName);
  try

    Self.WPSApplication1.Connect;
    Self.WPSApplication1.Visible:=True;
    Self.WPSApplication1.Activate;

    //it does not work
    Self.WPSApplication1.Documents.Open('E:\quickdisk\Delphi\Delphi_Demo\2015_03_05_11_16_19_X7_TYPE_LIBRARY\00001.doc',EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam);
    Self.WPSApplication1.ActiveDocument.ExportAsFixedFormat('E:\quickdisk\Delphi\Delphi_Demo\2015_03_05_11_16_19_X7_TYPE_LIBRARY\00001.pdf',wdExportFormatPDF,False,wdExportOptimizeForOnScreen,wdExportAllDocument,0,0,wdExportDocumentContent,False,False,wdExportCreateNoBookmarks,False,False,False,EmptyParam);

    //Self.WPSApplication1.Documents.Add(EmptyParam,EmptyParam,EmptyParam,EmptyParam);

    //it does not work
    //Self.WPSApplication1.ActiveDocument.ExportAsFixedFormat('00001.pdf',wdExportFormatPDF,False,wdExportOptimizeForOnScreen,wdExportAllDocument,0,0,wdExportDocumentContent,False,False,wdExportCreateNoBookmarks,False,False,False,EmptyParam);

    //it does not work
    //Self.WPSApplication1.Documents.Item(0).ExportAsFixedFormat('00003.pdf',wdExportFormatPDF);

    Self.WPSApplication1.Disconnect;
  finally
    //Self.WPSApplication1.Quit;
  end;
end;

end.
